package com.ruoyi.exam.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.exam.domain.PaperDetailQuestionResult;
import com.ruoyi.exam.service.IPaperDetailQuestionResultService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 考试试卷题目选项Controller
 * 
 * @author luqian
 * @date 2024-07-10
 */
@RestController
@RequestMapping("/paperDetailQuestionResult")
public class PaperDetailQuestionResultController extends BaseController
{
    @Autowired
    private IPaperDetailQuestionResultService paperDetailQuestionResultService;

    /**
     * 查询考试试卷题目选项列表
     */
    @RequiresPermissions("exam:paperDetailQuestionResult:list")
    @GetMapping("/list")
    public TableDataInfo list(PaperDetailQuestionResult paperDetailQuestionResult)
    {
        startPage();
        List<PaperDetailQuestionResult> list = paperDetailQuestionResultService.selectPaperDetailQuestionResultList(paperDetailQuestionResult);
        return getDataTable(list);
    }

    /**
     * 导出考试试卷题目选项列表
     */
    @RequiresPermissions("exam:paperDetailQuestionResult:export")
    @Log(title = "考试试卷题目选项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PaperDetailQuestionResult paperDetailQuestionResult)
    {
        List<PaperDetailQuestionResult> list = paperDetailQuestionResultService.selectPaperDetailQuestionResultList(paperDetailQuestionResult);
        ExcelUtil<PaperDetailQuestionResult> util = new ExcelUtil<PaperDetailQuestionResult>(PaperDetailQuestionResult.class);
        util.exportExcel(response, list, "考试试卷题目选项数据");
    }

    /**
     * 获取考试试卷题目选项详细信息
     */
    @RequiresPermissions("exam:paperDetailQuestionResult:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(paperDetailQuestionResultService.selectPaperDetailQuestionResultById(id));
    }

    /**
     * 新增考试试卷题目选项
     */
    @RequiresPermissions("exam:paperDetailQuestionResult:add")
    @Log(title = "考试试卷题目选项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaperDetailQuestionResult paperDetailQuestionResult)
    {
        return toAjax(paperDetailQuestionResultService.insertPaperDetailQuestionResult(paperDetailQuestionResult));
    }

    /**
     * 修改考试试卷题目选项
     */
    @RequiresPermissions("exam:paperDetailQuestionResult:edit")
    @Log(title = "考试试卷题目选项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaperDetailQuestionResult paperDetailQuestionResult)
    {
        return toAjax(paperDetailQuestionResultService.updatePaperDetailQuestionResult(paperDetailQuestionResult));
    }

    /**
     * 删除考试试卷题目选项
     */
    @RequiresPermissions("exam:paperDetailQuestionResult:remove")
    @Log(title = "考试试卷题目选项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(paperDetailQuestionResultService.deletePaperDetailQuestionResultByIds(ids));
    }
}
